import request from "@/utils/request";
import type {
  MachineGroupDTO,
  MachineGroupPageQry,
  MachineGroupSaveCmd,
  PageDTO,
  R
} from "@/types";

function getMachineGroup(id: string): Promise<R<MachineGroupDTO>> {
  return request.get("/api/machine-group/get-by-id", { params: { id } });
}

function getMachineGroupList(qry: MachineGroupPageQry): Promise<R<PageDTO<MachineGroupDTO>>> {
  return request.get("/api/machine-group/page", { params: qry });
}

function saveMachineGroup(cmd: MachineGroupSaveCmd): Promise<R<string>> {
  return request.post("/api/machine-group/save", cmd);
}

function deleteMachineGroup(id: string): Promise<R<string>> {
  return request.post("/api/machine-group/delete", {}, { params: { id } });
}

export default {
  getMachineGroupList,
  saveMachineGroup,
  getMachineGroup,
  deleteMachineGroup
};
